package com.witte.serviceImp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.witte.dao.ChancePlanMapper;
import com.witte.dao.CustomerPlanMapper;
import com.witte.entity.ChancePlan;
import com.witte.entity.CustomerPlan;
import com.witte.service.ChancePlanService;

@Service
public class ChancePlanServiceImp implements ChancePlanService{
	@Autowired
	CustomerPlanMapper mapper;
	
	@Autowired
	ChancePlanMapper chanceMapper;

	@Override
	public List<CustomerPlan> selectByPage(String username,Integer beginPage, Integer pageSize) {
		int page=(beginPage-1)*pageSize;
		if(username==null || username.equals(""))
			return mapper.selectByPage(page, pageSize);
		else
			return mapper.selectByPageName(username,page, pageSize);
			
	}
	
	@Override
	public int getTotle(String username) {
		if(username==null || username.equals(""))
			return mapper.getTotle();
		else
			return mapper.getTotleByName(username);
			
	}

	@Override
	public List<CustomerPlan> search(String username,String content) {
		if(username==null || username.equals(""))
			return mapper.search(content);
		else
			return mapper.searchUseName(username, content);
	}

	@Override
	public int addPlan(ChancePlan chancePlan) {
		return chanceMapper.insertSelective(chancePlan);
	}

	@Override
	public List<ChancePlan> getPlans(String id) {
		return chanceMapper.selectByPlanchanceid(id);
	}
	
}
